<?php
// L3 MIAGE Nice - Gestion de projets et Analyse des besoins - 2010-2011
// Création d'un site internet de vente de vidéos en ligne
// 
// compte.php - Formulaire de modification d'un utilisateur
// 
// Auteur : (groupe 15) Shyn-Yuan CHENG, Abdoul Mazid DIALLO, LAGNEAU Sébastien, NJOTCHA-NJOTCHA Franck-Merlin

// Vérifier que le fichier est inclus à index.php et vérifier que l'utilisateur soit connecté
// Sinon arrêter le script
//
if(!defined("VERIFINCLUDE") || VERIFINCLUDE!=0 || !isset($_SESSION["loginCl"]) || $_SESSION["loginCl"] == "") die();
include_once("includes/functions_date.php");

// Connexion à la BD mysql
//
try {
   $db = dbfactory::factory ("mysql");
} catch (Exception $e) {
   die($e->getmessage());
}

$loginCl= $_SESSION["loginCl"];
$sql= "SELECT * FROM client WHERE loginCl='$loginCl'";
$requete= $db->query($sql);
$nb= $db->num_rows();
if($nb!=1) die();

$client= $db->fetch_object();

$loginCl= htmlentities($client->loginCl, ENT_QUOTES, "UTF-8");
$nomCl= htmlentities($client->nomCl, ENT_QUOTES, "UTF-8");
$pnomCl= htmlentities($client->pnomCl, ENT_QUOTES, "UTF-8");
$DN= htmlentities(convdate($client->DN), ENT_QUOTES, "UTF-8");
$adresse= htmlentities($client->adresse, ENT_QUOTES, "UTF-8");
$cp= htmlentities($client->cp, ENT_QUOTES, "UTF-8");
$ville= htmlentities($client->ville, ENT_QUOTES, "UTF-8");
$tel= htmlentities($client->tel, ENT_QUOTES, "UTF-8");
$email= htmlentities($client->email, ENT_QUOTES, "UTF-8");

?>
   <script type="text/javascript" src="js/modification.js"></script>
   <form  action = ""  method = "POST" onsubmit="modifier(this.loginCl.value, this.mdpClA.value, this.mdpCl.value, this.c_mdpCl.value, this.nomCl.value, this.pnomCl.value, this.DN.value, this.adresse.value, this.cp.value, this.ville.value, this.pays.value, this.tel.value, this.email.value, this.c_email.value); return false;">
      <table id="formInscriptionCl">
         <tr>
            <td><label for="loginCl">Login : </label></td>  
            <td><input type="text" name="loginCl" id="loginCl" tabindex="10"  size="20" maxlength="15" disabled="disabled" value="<?php print($loginCl); ?>" /></td>
         </tr>
         <tr>
            <td><label for="mdpClA">Mot de passe actuel : </label> </td>
            <td><input type="password" name="mdpClA" id="mdpClA" tabindex="20"  size="20" maxlength="15" /></td>
	      </tr>
         <tr>
            <td><label for="mdpCl">Nouveau mot de passe : </label> </td>
            <td><input type="password" name="mdpCl" id="mdpCl" tabindex="20"  size="20" maxlength="15" /></td>
         </tr>
         <tr>
            <td><label for="c_mdpCl">Confirmer mot de passe : </label> </td>
            <td><input type="password" name="c_mdpCl" id="c_mdpCl" tabindex="21"  size="20" maxlength="15" /></td>
         </tr>
         <tr>
            <td><label for="nomCl">Nom : </label></td> 
            <td><input type="text" name="nomCl" id="nomCl" tabindex="30"  size="20" maxlength="50" value="<?php print($nomCl); ?>" /></td>
         </tr>
         <tr>
            <td><label for="pnomCl">Prenom : </label></td> 
            <td><input type="text" name="pnomCl" id="pnomCl" tabindex="40"  size="20" maxlength="50" value="<?php print($pnomCl); ?>" /></td>
	      </tr>
         <tr>
            <td><label for="DN">Date de naissance : </label></td>
            <td><input type="text" name="DN" id="DN" tabindex="50"  size="10" maxlength="10" value="<?php print($DN); ?>" /></td>
         </tr>
         <tr>
             <td><label for="adresse">Adresse : </label></td>
             <td><input type="text" name="adresse" id="adresse" tabindex="60"  size="20" maxlength="100" value="<?php print($adresse); ?>" /></td>
	      </tr>
         <tr>
             <td><label for="cp">Code postal : </label></td>
             <td><input type="text" name="cp" id="cp" tabindex="70"  size="5" maxlength="10" value="<?php print($cp); ?>" /></td>
         </tr>
         <tr>
             <td><label for="ville">Ville : </label></td>
             <td><input type="text" name="ville" id="ville" tabindex="80"  size="20" maxlength="30" value="<?php print($ville); ?>" /></td>
         </tr>
         <tr>
             <td><label for="pays" >Pays : </label>
                 <td>
                     <select name="pays" id="pays" tabindex="90">
                        <option value="france" selected="selected">France</option>
                        <option value="chine">Chine</option>
                        <option value="guin&eacute;e">Guin&eacute;e</option>
                        <option value="cameroun">Cameroun</option>
                        <option value="espagne">Espagne</option>
                        <option value="italie">Italie</option>
                        <option value="royaume-uni">Royaume-Uni</option>
                        <option value="canada">Canada</option>
                        <option value="etats-unis">Etats-Unis</option>
                        <option value="japon">Japon</option>
                     </select>
                  </td>  
         </tr>
         <tr>
            <td><label for="tel">Num&eacute;ro de t&eacute;l&eacute;phone : </label></td>
            <td><input type="text" name="tel" id="tel" tabindex="100"  size="10" maxlength="10" value="<?php print($tel); ?>" /></td>
         </tr>
         <tr>
            <td><label for="email">Email : </label></td>
            <td><input type="text" name="email" id="email" tabindex="110"  size="20" maxlength="50" value="<?php print($email); ?>" /></td>
         </tr>
         <tr>
            <td><label for="c_email">Confirmer email : </label></td>
            <td><input type="text" name="c_email" id="c_email" tabindex="111"  size="20" maxlength="50" /></td>
         </tr>
         <tr>
            <td><input type="submit" value="Enregistrer" name= "connecter" tabindex="120"></td>
            <td><input type="reset" value="Annuler" name= "effacer" tabindex="130"/></td>
         </tr>
      </table>
   <div id="msg"></div>
</form>
